@echo off

SET "url="
SET "needDelete=false"
IF "%~1"=="app" (
  SET "url=./app_library/"
) ELSE IF "%~1"=="core" (
  SET "url=./lib_core/"
) ELSE IF "%~1"=="ui" (
  SET "url=./lib_ui/"
) ELSE IF "%~1"=="community" (
  SET "url=./business_community/"
) ELSE IF "%~1"=="device" (
  SET "url=./business_device/"
) ELSE IF "%~1"=="scene" (
  SET "url=./business_scene/"
) ELSE IF "%~1"=="user" (
  SET "url=./business_user/"
) ELSE (
  SET "url="
)
IF "%~2"=="t" (
  SET "needDelete=true"
) ELSE (
  SET "needDelete=false"
)
IF "%url%" "=" "" (
  echo "选择择你需要生成代码的模块，如 ./runner_build.sh common 或 ./runner_build.sh common t"
  exit
)
IF "%needDelete%" == "true" (
  cd %url%
  echo "flutter packages pub run build_runner build --delete-conflicting-outputs"
  flutter pub run build_runner build --delete-conflicting-outputs
  cd ..
) ELSE (
  cd "%url%"
  echo "flutter packages pub run build_runner build"
  flutter pub run build_runner build
  cd ..
)